package com.hry.springboot.dynamic.datasource.config;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @Desc 数据源配置
 * @Author houruiyang
 * @Date 2021/8/31
 **/
@Configuration
public class DynamicDataSourceConfig {

    @Bean(name = "online")
    @ConfigurationProperties(prefix = "spring.datasource.druid.online")
    public DataSource onlineDataSource() {
        return DruidDataSourceBuilder.create().build();
    }

    @Bean(name = "local")
    @ConfigurationProperties(prefix = "spring.datasource.druid.local")
    public DataSource localDataSource() {
        return DruidDataSourceBuilder.create().build();
    }

}
